
#测试
import os
import pandas as pd
import math

from function.data_deal import stage_maxhr, compar_rr, compar_hr
from function.fun_data_deal import find_elements_with_substrings, group_by_prefix, longest_common_substring, max_hr, \
    stage_divide, df_get, compar_all
from other_function.check import check, ecg_check, singledetail_check, singlework_check, file_check, stage_check, time_check
from function.merger import merger,to_csv
from other_function.align import ecgrr_ppgrr, all_align

#测试,返回deal中的df数据


deal_path='D:\\学习&科研\\华为手表项目\\华为数据\\deal'
subject_path = 'D:\\学习&科研\\华为手表项目\\华为数据\\subject'
person='1128'
test=person+'-1-1'

# info_path=deal_path+'\\'+'stage'+'\\'+test+'-stage.csv'
# tocsv 可直接使用,个别问题再使用problemhanding 运行一遍
to_csv(subject_path,deal_path,person)
ecg_df,rrdata_df,ppg_df,rri_df,singlework_df,singledetail_df=df_get(deal_path, person, test)
# all_align(ecg_df,rrdata_df,ppg_df,rri_df,singlework_df,singledetail_df,person,test)
# stage_maxhr(rrdata_df,ecg_df,test)
# compar_rr(ecg_df,rrdata_df,rri_df,step=0)





# compar_hr=compar_hr(ecg_df,rrdata_df,singledetail_df)
# compar_hr.to_csv(r'D:\学习&科研\华为手表项目\华为数据\compare_hr'+'\\'+test+'compare_rr.csv')
# compar_all(all_df)
# time_check(ppg_df,singledetail_df,singlework_df)
# # stage_check(ecg_df,test)
# #
max_hr(rrdata_df)
# stage_maxhr(rrdata_df,ecg_df,test)

#所有数据都对齐


 # 测试

# ecg_deal(r'1008-1-1-2024-06-21-15时28分17秒ecg.csv')
# rri_deal(r'D:\codeproject\subject\1008\1008-1-1-rri.txt')
# ppg_deal(r'D:\codeproject\subject\1008\1008-1-1-ppg.txt')
# singledetail_deal(r'D:\codeproject\subject\1008\1008-1-1-singledetail.txt')
# singlework_deal(r'D:\codeproject\subject\1008\1008-1-1-singlework.txt')
# rrdata_deal(r'D:\codeproject\subject\1008\1008-1-1-2024-06-21-15时28分17秒rrdata.csv')

# df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-ecg.csv')
# ecg_check(df)


 # 最大心率测试
# df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-rrdata.csv')
# max_hr(df)

# #运动详情检查测试
# df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-singledetail.csv')
# print(singledetail_check(df))
#运动总记录
# df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-singlework.csv')
# print(singlework_check(df))




#ecg处理
# df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-ecg.csv')
# q_ecg(df)


# #ecg rr   和  ppg rr 对齐
# start_time = '2024-06-21 15:48:48'
# end_time = '2024-06-21 16:00:48'
# ecgrr_df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-rrdata.csv',dtype=str)
# ppgrr_df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-rri.csv',dtype=str)
# ecgrr_ppgrr(ecgrr_df,ppgrr_df,start_time,end_time)




#跑步阶段划分测试
# ecg_df = pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1033\1033-1-1-ecg.csv', dtype=str)
# stage_divide(ecg_df)

# rr_df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-rrdata.csv')
# print(rr_df)
# max_hr(rr_df)


# 检查测试
# file_check(r'D:\学习&科研\华为手表项目\华为数据\deal\1008')

#每个阶段的最大心率
# ecg_df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-ecg.csv')
# rrdata_df=pd.read_csv(r'D:\学习&科研\华为手表项目\华为数据\deal\1008\1008-1-1-rrdata.csv')
# stage_df=stage_maxhr(rrdata_df,ecg_df,test)
# stage_df.to_csv(info_path,index=False)

